<%@ page import="java.beans.VetoableChangeListener" %>
<%@ page import="java.util.Vector" %>
<%@ page import="com.drophair.jspwork.bean.Sqlgoods" %><%--
  Created by IntelliJ IDEA.
  User: drophair
  Team: 深藏blow
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>购物车</title>
    <script src="/js/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
</head>
<body background="/img/bg2.jpg">
<h1>购物车</h1>
<hr>
<%
    String error = "";
    error = (String) request.getAttribute("error");
    if (error != null && !error.equals("")){%>
        <%=error%>
    <%}%>
<form action="BuyGoodsServlet" method="post">
    <%
        Sqlgoods sqlgoods = new Sqlgoods();
        Vector<Vector<String>> vectors = new Vector<Vector<String>>();
        vectors = sqlgoods.getCartInfo();

        if(vectors.size()==0){%>
    <span>购物车空空如也，快去购买吧</span>
    <%}else{
        for (Vector vector : vectors) {
            String goodid = "";
            String goodname = "";
            goodid = (String) vector.get(0);
            goodname = (String) vector.get(1);
            System.out.println(goodid + "********" + goodname);%>
    <input type="checkbox" name="goodchecked" value="<%=goodid%>"><a><img src="/img/li.png"
                                                                            style="height: 20%"><%=goodname%>
</a><br>
    <%}%>
    <strong><hr></strong>
    <br>
    <br>
    <div style="float:right;width:10rem;overflow:hidden;">
        <input type="submit" value="购买">
        <a href="ClearCartServlet" style="display: inline-block">清空购物车</a>
    </div>
    <%}%>
</form>
</body>
</html>
